/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Interface;
import Base.Dados;
import Base.Perguntas;
import Base.Tema;
import Controle.ControlePergunta;
import Controle.ControleTema;
import java.util.ArrayList;


public class Questoes extends javax.swing.JFrame {
    ControleTema dt = new ControleTema();
    private ControlePergunta cp = new ControlePergunta();
    private ArrayList<Dados> lista;
    private Tema listatema[];
      
    
    /**
     * Creates new form Inicial
     */
     public Questoes() {
        initComponents();
        
        preencherComboBox();  
        lista = cp.buscarDados(); 
    }
      public void preencherComboBox(){
        listatema = dt.getTemas(); 
        Tema todos = new Tema(-1, "Todos os Temas");
        jComboBox1.addItem(todos);
        for(int i = 0; i<listatema.length; i++)
        {
            jComboBox1.addItem(listatema[i]);
        }
        
    }
      

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jButton1 = new javax.swing.JButton();
        btnQuestao3 = new javax.swing.JButton();
        lblTituloTema = new javax.swing.JLabel();
        btnQuestao1 = new javax.swing.JButton();
        btnQuestao2 = new javax.swing.JButton();
        lblTituloQuestao = new javax.swing.JLabel();
        jComboBox1 = new javax.swing.JComboBox();
        lblVoltar = new javax.swing.JLabel();
        lblFundo = new javax.swing.JLabel();

        jButton1.setText("jButton1");

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Quiz Responda e Aprenda");
        setResizable(false);
        getContentPane().setLayout(null);

        btnQuestao3.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        btnQuestao3.setText("20 Questões");
        btnQuestao3.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
        btnQuestao3.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        btnQuestao3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnQuestao3ActionPerformed(evt);
            }
        });
        getContentPane().add(btnQuestao3);
        btnQuestao3.setBounds(620, 390, 200, 60);

        lblTituloTema.setFont(new java.awt.Font("Andalus", 3, 48)); // NOI18N
        lblTituloTema.setText("Escolha o Tema do Quiz");
        lblTituloTema.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        getContentPane().add(lblTituloTema);
        lblTituloTema.setBounds(180, 50, 550, 50);

        btnQuestao1.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        btnQuestao1.setText("10 Questões");
        btnQuestao1.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
        btnQuestao1.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        btnQuestao1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnQuestao1ActionPerformed(evt);
            }
        });
        getContentPane().add(btnQuestao1);
        btnQuestao1.setBounds(70, 390, 200, 60);

        btnQuestao2.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        btnQuestao2.setText("15 Questões");
        btnQuestao2.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
        btnQuestao2.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        btnQuestao2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnQuestao2ActionPerformed(evt);
            }
        });
        getContentPane().add(btnQuestao2);
        btnQuestao2.setBounds(350, 450, 200, 60);

        lblTituloQuestao.setFont(new java.awt.Font("Andalus", 3, 48)); // NOI18N
        lblTituloQuestao.setText("Escolha a Quantidade de Questões");
        lblTituloQuestao.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        getContentPane().add(lblTituloQuestao);
        lblTituloQuestao.setBounds(70, 280, 780, 50);

        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel());
        jComboBox1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        getContentPane().add(jComboBox1);
        jComboBox1.setBounds(280, 160, 330, 30);

        lblVoltar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/voltar.png"))); // NOI18N
        lblVoltar.setText("VOLTAR");
        lblVoltar.setToolTipText("Voltar");
        lblVoltar.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        lblVoltar.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                lblVoltarMouseClicked(evt);
            }
        });
        getContentPane().add(lblVoltar);
        lblVoltar.setBounds(810, 520, 80, 40);

        lblFundo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/fundo2.png"))); // NOI18N
        getContentPane().add(lblFundo);
        lblFundo.setBounds(0, 0, 930, 580);

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-927)/2, (screenSize.height-606)/2, 927, 606);
    }// </editor-fold>//GEN-END:initComponents

    private void btnQuestao3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnQuestao3ActionPerformed
        
        Perguntas.lista = cp.getRespostas(((Tema)jComboBox1.getSelectedItem()).getId());
        Perguntas.totalPerguntas = 20;
        Perguntas.ajustarLista();
        Pergunta p = new Pergunta();
        p.setVisible(true);
        this.setVisible(false);
    }//GEN-LAST:event_btnQuestao3ActionPerformed

    private void btnQuestao1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnQuestao1ActionPerformed

        Perguntas.lista = cp.getRespostas(((Tema)jComboBox1.getSelectedItem()).getId());
        Perguntas.totalPerguntas = 10; 
        Perguntas.ajustarLista();
        Pergunta p = new Pergunta();
        p.setVisible(true);
        this.setVisible(false);
    }//GEN-LAST:event_btnQuestao1ActionPerformed

    private void btnQuestao2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnQuestao2ActionPerformed

        Perguntas.lista = cp.getRespostas(((Tema)jComboBox1.getSelectedItem()).getId());
        Perguntas.totalPerguntas = 15;
        Perguntas.ajustarLista();
        Pergunta p = new Pergunta(); 
        p.setVisible(true);
        this.setVisible(false);
    }//GEN-LAST:event_btnQuestao2ActionPerformed

    private void lblVoltarMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblVoltarMouseClicked
        Inicial in = new Inicial();
        in.setVisible(true);
        this.setVisible(false);
    }//GEN-LAST:event_lblVoltarMouseClicked

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Inicial.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Inicial.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Inicial.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Inicial.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new Questoes().setVisible(true);
            }
        });
    }
    
    
    private int a = 0;
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnQuestao1;
    private javax.swing.JButton btnQuestao2;
    private javax.swing.JButton btnQuestao3;
    private javax.swing.JButton jButton1;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JLabel lblFundo;
    private javax.swing.JLabel lblTituloQuestao;
    private javax.swing.JLabel lblTituloTema;
    private javax.swing.JLabel lblVoltar;
    // End of variables declaration//GEN-END:variables
}
